App({
  globalData: {
    userInfo: null,
    token: null,
    // 模拟数据
    mockUserInfo: {
      nickName: '海大力',
      avatarUrl: '/assets/images/default-avatar.png',
      gender: 1,
      country: '中国',
      province: '广东',
      city: '深圳'
    }
  },
  
  onLaunch() {
    // 直接使用模拟数据
    this.globalData.userInfo = this.globalData.mockUserInfo;
    this.globalData.token = 'mock-token-' + Date.now();
    
    // 存储到本地
    wx.setStorageSync('userInfo', this.globalData.mockUserInfo);
    wx.setStorageSync('token', this.globalData.token);
  },

  checkLoginStatus() {
    const token = wx.getStorageSync('token');
    if (token) {
      this.globalData.token = token;
      this.getUserInfo();
    } else {
      this.login();
    }
  },

  login() {
    // 模拟登录
    setTimeout(() => {
      const mockToken = 'mock-token-' + Date.now();
      this.globalData.token = mockToken;
      this.globalData.userInfo = this.globalData.mockUserInfo;
      wx.setStorageSync('token', mockToken);
      wx.setStorageSync('userInfo', this.globalData.mockUserInfo);
    }, 500);
  },

  getUserInfo() {
    // 直接返回模拟数据
    this.globalData.userInfo = this.globalData.mockUserInfo;
    wx.setStorageSync('userInfo', this.globalData.mockUserInfo);
  }
}); 